FROM rockylinux:9.3

LABEL maintainer="hukanfa" \
      description="RocketMQ Exporter for Prometheus" \
      version="0.0.2"

# 安装OpenJDK 8（包括开发工具包）
RUN dnf install -y \
    java-1.8.0-openjdk \
    java-1.8.0-openjdk-devel \
    && dnf clean all

# 设置JAVA_HOME环境变量（OpenJDK 8默认安装路径）
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk
# 将Java加入PATH
ENV PATH $PATH:$JAVA_HOME/bin

# 替换为阿里云镜像源并安装工具
RUN dnf -y install net-tools telnet \
    && ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && dnf clean all

# 工作目录
WORKDIR /app

# 复制jar包
COPY rocketmq-exporter-0.0.2-exec.jar rocketmq-exporter.jar

# 暴露端口
EXPOSE 5557

# 启动命令
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar rocketmq-exporter.jar --rocketmq.config.namesrvAddr=${ROCKETMQ_NAMESRV_ADDR}"]